const fs = require('fs');
const path = require('path');

function getBase64FromImage(imageName) {
  try {
    // 直接读取已转换好的base64文件
    const base64Path = path.resolve(__dirname, '../../../downloads', imageName.replace('.jpg', '.base64.txt'));
    return fs.readFileSync(base64Path, 'utf8');
  } catch (error) {
    console.error(`Error reading base64 file for ${imageName}:`, error);
    return null;
  }
}

module.exports = { getBase64FromImage };
